package ru.susu.algebra.belonogov;

import ru.susu.algebra.operation.IOperation;
import ru.susu.algebra.partition.Partition;
import ru.susu.algebra.partition.operation.CoverPartitionOperation;
import ru.susu.algebra.partition.operation.DeltaMPartitionOperation;
import ru.susu.algebra.partition.operation.IncreaseBiggerElementPartitionOp;
import ru.susu.algebra.partition.operation.ChangePartitionElementOperation;
import ru.susu.algebra.partition.operation.SumMPartitionOperation;

/**
 * @author akargapolov
 * @since: 03.06.2009
 */
public abstract class ProportionalCharactersViewerBase implements Runnable
{
	protected static int MAX_VALUE = 80;

	public static void main(String[] args) throws Exception
	{
		//программа потоконебезопасная, вместе два лучше не запускать))
		//new Thread(new ProportionalCharactersSnAnViewer()).start();
		new Thread(new ProportionalCharactersSnNAnViewer()).start();
	}

	IOperation<Partition> addOp = new IncreaseBiggerElementPartitionOp();
	IOperation<Partition> coverOp = new CoverPartitionOperation();
	IOperation<Partition> increaseOp = new ChangePartitionElementOperation();
	IOperation<Partition> deltaOp = new DeltaMPartitionOperation();
	IOperation<Partition> sumOp = new SumMPartitionOperation();

	public void run()
	{
		try
		{
			createPartitions();
			writePartitions();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}

	protected Partition addBasePower(Partition partition, int base, int k)
	{
		IOperation<Partition> operation = new CoverPartitionOperation();
		Partition result = partition;
		for (int i = 0; i < k; i++)
		{
			result = operation.performOperation(base, result);
		}
		return result;
	}

	protected abstract void writePartitions() throws Exception;

	protected abstract void createPartitions() throws Exception;
}
